package com.ruoyi.rms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.rms.domain.WaitMessage;
import com.ruoyi.rms.service.IWaitMessageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 排队信息Controller
 * 
 * @author wyl
 * @date 2024-03-08
 */
@RestController
@RequestMapping("/rms/wait")
public class WaitMessageController extends BaseController
{
    @Autowired
    private IWaitMessageService waitMessageService;

    /**
     * 查询排队信息列表
     */
//    @PreAuthorize("@ss.hasPermi('rms:wait:list')")
    @GetMapping("/list")
    public TableDataInfo list(WaitMessage waitMessage)
    {
        startPage();
        List<WaitMessage> list = waitMessageService.selectWaitMessageList(waitMessage);
        return getDataTable(list);
    }

    /**
     * 查询排队信息列表 不分页
     */
//    @PreAuthorize("@ss.hasPermi('rms:wait:list')")
    @GetMapping("/allData")
    public AjaxResult allData(WaitMessage waitMessage)
    {
        return AjaxResult.success(waitMessageService.selectWaitMessageList(waitMessage));
    }

    /**
     * 导出排队信息列表
     */
//    @PreAuthorize("@ss.hasPermi('rms:wait:export')")
    @Log(title = "排队信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WaitMessage waitMessage)
    {
        List<WaitMessage> list = waitMessageService.selectWaitMessageList(waitMessage);
        ExcelUtil<WaitMessage> util = new ExcelUtil<WaitMessage>(WaitMessage.class);
        util.exportExcel(response, list, "排队信息数据");
    }

    /**
     * 获取排队信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('rms:wait:query')")
    @GetMapping(value = "/{waitId}")
    public AjaxResult getInfo(@PathVariable("waitId") Long waitId)
    {
        return success(waitMessageService.selectWaitMessageByWaitId(waitId));
    }

    /**
     * 新增排队信息
     */
//    @PreAuthorize("@ss.hasPermi('rms:wait:add')")
    @Log(title = "排队信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WaitMessage waitMessage)
    {
        return waitMessageService.insertWaitMessage(waitMessage) > 0 ? AjaxResult.success("排队成功", waitMessage) : AjaxResult.error("排队失败");
    }

    /**
     * 修改排队信息
     */
//    @PreAuthorize("@ss.hasPermi('rms:wait:edit')")
    @Log(title = "排队信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WaitMessage waitMessage)
    {
        return toAjax(waitMessageService.updateWaitMessage(waitMessage));
    }

    /**
     * 删除排队信息
     */
//    @PreAuthorize("@ss.hasPermi('rms:wait:remove')")
    @Log(title = "排队信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{waitIds}")
    public AjaxResult remove(@PathVariable Long[] waitIds)
    {
        return toAjax(waitMessageService.deleteWaitMessageByWaitIds(waitIds));
    }
}
